#README: simple version of pic grabber, works through atomic2, modify board= to your need, 
#emulates a bbs reader who refreshes board in "post list" views, if see attachment, save all 
#saved files named att.php?n.board-id.post-id.atttachment-id.jpg, rename to board_post-id.att-id.jpg                                                                                
wget -O board.htm "http://www.newsmth.net/bbsdoc.php?board=picture" 
postnum=`cat board.htm |grep " @" | tail -1 | sed -e "s/c\.o(//g" |awk -F "," '{print $1}' ; `  
rm -f board.htm

#ifdef incremental_readings  
touch postnum.last; read lastpostnum < postnum.last;
if [ $postnum = $lastpostnum ]     
then  exit; # echo "same pic post again >_<!";  
fi                                
echo $postnum > postnum.last
#endif                                                                                                                                                                 
httpprefix="http://www.newsmth.net/atomic2.php?act=article&board=picture&id=" 
#act=article is fixed; board= pict*re/piel*ve/myph*to, etc need adjust to your needs 

posthttp=$httpprefix$postnum

wget -O post.htm $posthttp                                                                                                                                             
cat post.htm | tr -s "<li>" "\n" | grep "att\.php" | sed -e "s/.*att\.php/http:\/\/www\.newsmth\.net\/att\.php/g" | sed -e "s/' target=.*//g" > picurl.list            
rm -f post.htm

wget -nd -r -A jpg -i picurl.list
#rename -f "s/att\.php\?n\.//g" att*jpg                                                                                                                                
find . -name "att*jpg" | while read jpgfilename; do mv -f $jpgfilename $(echo $jpgfilename| sed -e "s/att.php?n.[0-9]*./picture_/g"); done

rm -f picurl.list 
#mogrify -resize 640x480 *.jpg  
